<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  

  
  <title>CSS基础知识点--CSS文本样式(text) | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="文本样式属性text-align设置元素内文本对齐方式 语法：  text-algin：left | right | center | justify  注：该属性只对块级元素的设置有效 line-height属性设置元素中文本行高 语法：  line-height：长度值 | 百分比  em/%都会相对于字体大小来变化 vertical-align设置元素内容的垂直方式 语法：  vertic">
<meta name="keywords" content="CSS">
<meta property="og:type" content="article">
<meta property="og:title" content="CSS基础知识点--CSS文本样式(text)">
<meta property="og:url" content="http://yoursite.com/2019/08/01/CSS基础知识点-cCSS文本样式/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="文本样式属性text-align设置元素内文本对齐方式 语法：  text-algin：left | right | center | justify  注：该属性只对块级元素的设置有效 line-height属性设置元素中文本行高 语法：  line-height：长度值 | 百分比  em/%都会相对于字体大小来变化 vertical-align设置元素内容的垂直方式 语法：  vertic">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2019-08-01T14:34:56.424Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="CSS基础知识点--CSS文本样式(text)">
<meta name="twitter:description" content="文本样式属性text-align设置元素内文本对齐方式 语法：  text-algin：left | right | center | justify  注：该属性只对块级元素的设置有效 line-height属性设置元素中文本行高 语法：  line-height：长度值 | 百分比  em/%都会相对于字体大小来变化 vertical-align设置元素内容的垂直方式 语法：  vertic">
  
    <link rel="alternate" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
</head>
</html>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-CSS基础知识点-cCSS文本样式" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2019/08/01/CSS基础知识点-cCSS文本样式/" class="article-date">
  <time datetime="2019-08-01T07:16:05.000Z" itemprop="datePublished">2019-08-01</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/CSS/">CSS</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      CSS基础知识点--CSS文本样式(text)
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<h2 id="文本样式属性"><a href="#文本样式属性" class="headerlink" title="文本样式属性"></a>文本样式属性</h2><h3 id="text-align"><a href="#text-align" class="headerlink" title="text-align"></a>text-align</h3><p>设置元素内文本对齐方式</p>
<p>语法：</p>
<blockquote>
<p>text-algin：left | right | center | justify</p>
</blockquote>
<p>注：该属性只对块级元素的设置有效</p>
<h3 id="line-height属性"><a href="#line-height属性" class="headerlink" title="line-height属性"></a>line-height属性</h3><p>设置元素中文本行高</p>
<p>语法：</p>
<blockquote>
<p>line-height：长度值 | 百分比</p>
</blockquote>
<p>em/%都会相对于字体大小来变化</p>
<h3 id="vertical-align"><a href="#vertical-align" class="headerlink" title="vertical-align"></a>vertical-align</h3><p>设置元素内容的垂直方式</p>
<p>语法：</p>
<blockquote>
<p>vertical-align：baseline(默认) | sub | super | top | text-top | middle | bottom | text-bottom | 长度 | 百分比</p>
</blockquote>
<p>说明：</p>
<ul>
<li><p>对行内元素有效，对块级元素无效</p>
</li>
<li><p>长度和百分比，上移为正，下移为负</p>
</li>
</ul>
<h3 id="水平居中与垂直居中"><a href="#水平居中与垂直居中" class="headerlink" title="水平居中与垂直居中"></a>水平居中与垂直居中</h3><p>技巧：</p>
<ul>
<li><p>单行文字垂直居中：将line-height属性设置和元素一样高</p>
</li>
<li><p>单行文字水平对齐：text-align：center</p>
</li>
<li><p>多行文字垂直居中：</p>
<ol>
<li><p>先用display属性将div转换为table的表格元素，变为行内元素（display：table-cell），同时也将div的父元素div也转换为table元素（display：table）</p>
</li>
<li><p>再用vertical-align：middle将单元格垂直居中</p>
</li>
</ol>
</li>
<li><p>多行文字水平居中：text-align：center</p>
</li>
</ul>
<h3 id="其他文本样式"><a href="#其他文本样式" class="headerlink" title="其他文本样式"></a>其他文本样式</h3><table>
<thead>
<tr>
<th>字体属性</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>word-spacing</td>
<td>设置元素内<font color="red">单词</font>之间间距</td>
</tr>
<tr>
<td>letter-spacing</td>
<td>设置元素内<font color="red">字母</font>之间间距</td>
</tr>
<tr>
<td>text-transform</td>
<td>设置元素内文本的大小写  capitalize / uppercase / lowercase / none</td>
</tr>
<tr>
<td>text-decoration</td>
<td>设置元素内文本的装饰  underline / overline / line-through / blink / none</td>
</tr>
</tbody></table>
<h4 id="text-indent"><a href="#text-indent" class="headerlink" title="text-indent"></a>text-indent</h4><p>主要作用：首行缩进</p>
<p>例：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">text-indent:2em;</span><br></pre></td></tr></table></figure>

<h2 id="CSS文本样式应用"><a href="#CSS文本样式应用" class="headerlink" title="CSS文本样式应用"></a>CSS文本样式应用</h2><p>经验技巧：</p>
<ol>
<li><p>网页制作从整体到局部</p>
</li>
<li><p>借助手册和网络</p>
</li>
</ol>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2019/08/01/CSS基础知识点-cCSS文本样式/" data-id="cjz9j7sbc0001nkw081on76ev" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/CSS/">CSS</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2019/08/01/CSS基础知识点-CSS字体样式/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          CSS基础知识点--CSS字体样式(font)
        
      </div>
    </a>
  
  
    <a href="/2019/08/01/CSS基础知识点-CSS样式命名/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">CSS基础知识点--CSS样式命名</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Ajax/">Ajax</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/CSS/">CSS</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Git/">Git</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/HTML/">HTML</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/HTML5/">HTML5</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/JSON/">JSON</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Java/">Java</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/JavaScript/">JavaScript</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/QT/">QT</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/TheKnowledgeOf/">TheKnowledgeOf</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Ajax/">Ajax</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/CSS/">CSS</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Git/">Git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/HTML/">HTML</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/HTML5/">HTML5</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JSON/">JSON</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Java/">Java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript/">JavaScript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/QT/">QT</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/TheKnowledgeOf/">TheKnowledgeOf</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/Ajax/" style="font-size: 15px;">Ajax</a> <a href="/tags/CSS/" style="font-size: 20px;">CSS</a> <a href="/tags/Git/" style="font-size: 15px;">Git</a> <a href="/tags/HTML/" style="font-size: 17.5px;">HTML</a> <a href="/tags/HTML5/" style="font-size: 12.5px;">HTML5</a> <a href="/tags/JSON/" style="font-size: 10px;">JSON</a> <a href="/tags/Java/" style="font-size: 12.5px;">Java</a> <a href="/tags/JavaScript/" style="font-size: 15px;">JavaScript</a> <a href="/tags/QT/" style="font-size: 15px;">QT</a> <a href="/tags/TheKnowledgeOf/" style="font-size: 12.5px;">TheKnowledgeOf</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/08/">August 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/07/">July 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">June 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/05/">May 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">April 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">March 2019</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2019/08/11/HTML进阶知识点-HTML5属性变化/">HTML进阶知识点--HTML5属性变化</a>
          </li>
        
          <li>
            <a href="/2019/08/10/HTML进阶知识点-HTML5标签变化/">HTML进阶知识点--HTML5标签变化</a>
          </li>
        
          <li>
            <a href="/2019/08/08/CSS基础知识点-网页布局/">CSS基础知识点--网页布局</a>
          </li>
        
          <li>
            <a href="/2019/08/06/CSS基础知识点-CSS定位-position/">CSS基础知识点--CSS定位(position)</a>
          </li>
        
          <li>
            <a href="/2019/08/06/CSS基础知识点-float浮动/">CSS基础知识点--float浮动</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2019 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



  </div>
</body>
</html>